<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="utf-8">
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Page title -->
    <title>Petz - Pet HTML5 Template</title>
    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/foreground/js/respond.js"></script>
    <![endif]-->
    <!-- Bootstrap Core CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/bootstrap.css" rel="stylesheet" type="text/css">
    <!-- Icon fonts -->
    <link href="${pageContext.request.contextPath}/foreground/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/flaticons/flaticon.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/glyphicons/bootstrap-glyphicons.css" rel="stylesheet" type="text/css">
    <!-- Google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Lato:400,800" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Baloo+Thambi" rel="stylesheet">
    <!-- Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/style.css" rel="stylesheet">
    <!-- Plugins CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/foreground/css/plugins.css">
    <!-- Color Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/styles/maincolors.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/background/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/js/xadmin.js"></script>


</head>
<body>
<%--导航栏--%>
<%@ include file="../common/topbar.jsp" %>

<section id="contact" class="pages no-padding">
    <!-- 最中间的那个蓝色椭圆标题 -->
    <div class="jumbotron" data-stellar-background-ratio="0.5">
        <div class="jumbo-heading" data-stellar-background-ratio="1.2">
            <h1>用户注册</h1>
        </div>
    </div>

    <!-- container -->
    <div class="container">
        <div class="row">
            <div class="col-lg-6 col-md-6 col-lg-offset-1 col-md-offset-1 res-margin">
                <h3>用户注册</h3>
                <form id="contact_form" action="##" onsubmit="return false">
                    <div class="form-group">
                        <label>用户名<span class="required">*</span></label>
                        <input type="text" name="username" class="form-control input-field" required="">
                        <label>密码</label>
                        <input type="text" name="password" class="form-control input-field" required="">
                    </div>
                    <div style="display: flex;flex-direction: row;">
                        <button onclick="register()" id="submit_btn" class="btn center-block" >注册</button>
                        <a href="user-login" class="btn center-block">登录</a>
                    </div>
                </form>
                <div id="contact_results"></div>
            </div>
        </div>
    </div>
    <div class="container-fluid margin1">
    </div>
</section>

    <script>
        /*用户-注册*/
        function register(){
            layer.confirm('确认要注册吗？',function(index){
                //发异步删除数据
                $.ajax({
                    url:"registerUser",
                    data:$('#contact_form').serialize(),//servlet按照"classobj_id"取值
                    type:"POST",
                    success:function(s){//从servlet获取返回数据data:{SUCCESS ERREO}
                        if(s=="SUCCESS"){
                            layer.msg('注册成功!',{icon:1,time:1000});
                        }else{
                            if(s=="已存在"){
                                layer.msg('用户已存在!',{icon:1,time:1000});
                            }else {
                                layer.alert(s,{title:"注册失败"});

                            }
                        }
                    }
                });
            });
        }
    </script>
</body>
</html>
